package Method;

import java.util.zip.Checksum;

public class Array {
    public static void main(String[] args) {
        int [] numbers; //声明一个数组numbers
        numbers =new int[10];//创建一个数组
        //给数组赋值
//        numbers [0] =1;
//        numbers [2] =2;
//        numbers [3] =1;
//        numbers [4] =4;
//        numbers [5] =5;
//        numbers [6] =6;
        //给数组赋值
//         for (int i = 0; i <= 9; i++) {
//            if (i>9 || i<0){
//                System.out.println("请输入10以内的数字");
//            }else{
//                numbers[i]=i+1;
//            }
//        }
        //给数组赋值
        for (int i= 0; i<numbers.length ; i++){
            numbers[i]=i+1;
        }
        //计算数组的和
        int sum =0;
        for (int i=0; i<numbers.length; i++){
            sum = sum +numbers[i];
        }
        System.out.println(numbers[9]);
        System.out.println(sum);
    }
}
